package com.gitee.fsmxm.ocon.util;

import com.gitee.fsmxm.ocon.constant.PpSaveAsFileType;

import java.util.Locale;

/**
 * @author fsmxm
 */
public final class PptUtils {
    private PptUtils() {
    }

    /**
     * params of open
     *
     * @param fileName   Required. The name of the file to open.
     * @param readOnly   Specifies whether the file is opened with read/write or read-only status.
     * @param untitled   Specifies whether the file has a title.
     * @param withWindow Specifies whether the file is visible.
     * @return params of open
     * @see <a href="https://docs.microsoft.com/en-us/office/vba/api/powerpoint.presentations.open">powerpoint.presentations.open</a>
     */
    public static Object[] paramOfOpen(String fileName,
                                       Boolean readOnly,
                                       Boolean untitled,
                                       Boolean withWindow) {
        return new Object[]{
                VT.get(fileName),
                VT.get(readOnly),
                VT.get(untitled),
                VT.get(withWindow)
        };
    }

    /**
     * get format type.
     * notice: wps not support in now version 11.1.0.9098 :
     * gif rtf xml
     *
     * @param targetExt target ext
     * @return format type
     */
    public static int getFormatType(String targetExt) {
        switch (targetExt.toLowerCase(Locale.ENGLISH)) {
            case "bmp":
                return PpSaveAsFileType.PP_SAVE_AS_BMP;
            case "gif":
                return PpSaveAsFileType.PP_SAVE_AS_GIF;
            case "jpg":
                return PpSaveAsFileType.PP_SAVE_AS_JPG;
            case "png":
                return PpSaveAsFileType.PP_SAVE_AS_PNG;
            case "pdf":
                return PpSaveAsFileType.PP_SAVE_AS_PDF;
            case "ppt":
                return PpSaveAsFileType.PP_SAVE_AS_PRESENTATION;
            case "pptx":
                return PpSaveAsFileType.PP_SAVE_AS_DEFAULT;
            case "rtf":
                return PpSaveAsFileType.PP_SAVE_AS_RTF;
            case "tif":
                return PpSaveAsFileType.PP_SAVE_AS_TIF;
            case "xml":
                return PpSaveAsFileType.PP_SAVE_AS_XML_PRESENTATION;
            default:
                return -1;
        }
    }
}
